package com.dailyblue.java.project.oa.quitlog.listener;

import com.alibaba.fastjson.JSONArray;
import com.dailyblue.java.project.oa.commons.bean.Emp;
import com.dailyblue.java.project.oa.commons.service.QuitLogService;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@RocketMQMessageListener(consumerGroup = "zhuoyue03",messageModel = MessageModel.BROADCASTING,topic = "QUIT")
public class QuitLogListener implements RocketMQListener<String> {
    @Resource
    private QuitLogService quitLogService;

    @Override
    public void onMessage(String s) {
        if(s==null){
            return;
        }
        Emp emp = JSONArray.parseObject(s,Emp.class);
        quitLogService.saveQuitLog(emp);
    }
}
